<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.13"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>lwIP: src/api/tcpip.c File Reference</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="navtreedata.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<script type="text/javascript">
  $(document).ready(initResizable);
</script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td id="projectalign" style="padding-left: 0.5em;">
   <div id="projectname">lwIP
   &#160;<span id="projectnumber">2.1.2</span>
   </div>
   <div id="projectbrief">Lightweight IP stack</div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.13 -->
<script type="text/javascript">
var searchBox = new SearchBox("searchBox", "search",false,'Search');
</script>
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
$(function() {
  initMenu('',true,false,'search.php','Search');
  $(document).ready(function() { init_search(); });
});
</script>
<div id="main-nav"></div>
</div><!-- top -->
<div id="side-nav" class="ui-resizable side-nav-resizable">
  <div id="nav-tree">
    <div id="nav-tree-contents">
      <div id="nav-sync" class="sync"></div>
    </div>
  </div>
  <div id="splitbar" style="-moz-user-select:none;" 
       class="ui-resizable-handle">
  </div>
</div>
<script type="text/javascript">
$(document).ready(function(){initNavTree('tcpip_8c.html','');});
</script>
<div id="doc-content">
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

<div class="header">
  <div class="summary">
<a href="#func-members">Functions</a> &#124;
<a href="#var-members">Variables</a>  </div>
  <div class="headertitle">
<div class="title">tcpip.c File Reference</div>  </div>
</div><!--header-->
<div class="contents">
<div class="textblock"><code>#include &quot;<a class="el" href="opt_8h.html">lwip/opt.h</a>&quot;</code><br />
<code>#include &quot;<a class="el" href="tcpip__priv_8h.html">lwip/priv/tcpip_priv.h</a>&quot;</code><br />
<code>#include &quot;<a class="el" href="sys_8h.html">lwip/sys.h</a>&quot;</code><br />
<code>#include &quot;<a class="el" href="memp_8h.html">lwip/memp.h</a>&quot;</code><br />
<code>#include &quot;<a class="el" href="mem_8h.html">lwip/mem.h</a>&quot;</code><br />
<code>#include &quot;<a class="el" href="init_8h.html">lwip/init.h</a>&quot;</code><br />
<code>#include &quot;<a class="el" href="ip_8h.html">lwip/ip.h</a>&quot;</code><br />
<code>#include &quot;<a class="el" href="pbuf_8h.html">lwip/pbuf.h</a>&quot;</code><br />
<code>#include &quot;<a class="el" href="lwip_2etharp_8h.html">lwip/etharp.h</a>&quot;</code><br />
<code>#include &quot;<a class="el" href="netif_2ethernet_8h.html">netif/ethernet.h</a>&quot;</code><br />
</div><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="func-members"></a>
Functions</h2></td></tr>
<tr class="memitem:a93043b3c66dbe4a15a60299c6199d102"><td class="memItemLeft" align="right" valign="top"><a class="el" href="group__infrastructure__errors.html#gaf02d9da80fd66b4f986d2c53d7231ddb">err_t</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="tcpip_8c.html#a93043b3c66dbe4a15a60299c6199d102">tcpip_inpkt</a> (struct <a class="el" href="structpbuf.html">pbuf</a> *p, struct <a class="el" href="structnetif.html">netif</a> *inp, <a class="el" href="netif_8h.html#ab2302b1b64ac7b95f24c6bab754a575e">netif_input_fn</a> input_fn)</td></tr>
<tr class="separator:a93043b3c66dbe4a15a60299c6199d102"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:gae510f195171bed8499ae94e264a92717"><td class="memItemLeft" align="right" valign="top"><a class="el" href="group__infrastructure__errors.html#gaf02d9da80fd66b4f986d2c53d7231ddb">err_t</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__lwip__os.html#gae510f195171bed8499ae94e264a92717">tcpip_input</a> (struct <a class="el" href="structpbuf.html">pbuf</a> *p, struct <a class="el" href="structnetif.html">netif</a> *inp)</td></tr>
<tr class="separator:gae510f195171bed8499ae94e264a92717"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:gaab838fe3417ab3a1f61f0728009a0c2a"><td class="memItemLeft" align="right" valign="top"><a class="el" href="group__infrastructure__errors.html#gaf02d9da80fd66b4f986d2c53d7231ddb">err_t</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__lwip__os.html#gaab838fe3417ab3a1f61f0728009a0c2a">tcpip_callback</a> (<a class="el" href="tcpip_8h.html#a35203296bb838f3b493839ffc6e7285d">tcpip_callback_fn</a> function, void *ctx)</td></tr>
<tr class="separator:gaab838fe3417ab3a1f61f0728009a0c2a"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:gaeb7b3c7414c76ad8dde14d2fba6cb020"><td class="memItemLeft" align="right" valign="top"><a class="el" href="group__infrastructure__errors.html#gaf02d9da80fd66b4f986d2c53d7231ddb">err_t</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__lwip__os.html#gaeb7b3c7414c76ad8dde14d2fba6cb020">tcpip_try_callback</a> (<a class="el" href="tcpip_8h.html#a35203296bb838f3b493839ffc6e7285d">tcpip_callback_fn</a> function, void *ctx)</td></tr>
<tr class="separator:gaeb7b3c7414c76ad8dde14d2fba6cb020"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a12bdf37eddcd72c4178e3ea7d370395d"><td class="memItemLeft" align="right" valign="top"><a class="el" href="group__infrastructure__errors.html#gaf02d9da80fd66b4f986d2c53d7231ddb">err_t</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="tcpip_8c.html#a12bdf37eddcd72c4178e3ea7d370395d">tcpip_send_msg_wait_sem</a> (<a class="el" href="tcpip_8h.html#a35203296bb838f3b493839ffc6e7285d">tcpip_callback_fn</a> fn, void *apimsg, sys_sem_t *sem)</td></tr>
<tr class="separator:a12bdf37eddcd72c4178e3ea7d370395d"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a3d42b0c46607f91aedcc7745ed466b08"><td class="memItemLeft" align="right" valign="top"><a class="el" href="group__infrastructure__errors.html#gaf02d9da80fd66b4f986d2c53d7231ddb">err_t</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="tcpip_8c.html#a3d42b0c46607f91aedcc7745ed466b08">tcpip_api_call</a> (tcpip_api_call_fn fn, struct tcpip_api_call_data *call)</td></tr>
<tr class="separator:a3d42b0c46607f91aedcc7745ed466b08"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:gaee14fa2587a9ba9d23e4c7e16c4526ac"><td class="memItemLeft" align="right" valign="top">struct tcpip_callback_msg *&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__lwip__os.html#gaee14fa2587a9ba9d23e4c7e16c4526ac">tcpip_callbackmsg_new</a> (<a class="el" href="tcpip_8h.html#a35203296bb838f3b493839ffc6e7285d">tcpip_callback_fn</a> function, void *ctx)</td></tr>
<tr class="separator:gaee14fa2587a9ba9d23e4c7e16c4526ac"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:gac5b7a59f4c3f5f721ab9ee81f231c9fd"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__lwip__os.html#gac5b7a59f4c3f5f721ab9ee81f231c9fd">tcpip_callbackmsg_delete</a> (struct tcpip_callback_msg *msg)</td></tr>
<tr class="separator:gac5b7a59f4c3f5f721ab9ee81f231c9fd"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga83fe5fb2ea33e8c262567ac46f4db3f8"><td class="memItemLeft" align="right" valign="top"><a class="el" href="group__infrastructure__errors.html#gaf02d9da80fd66b4f986d2c53d7231ddb">err_t</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__lwip__os.html#ga83fe5fb2ea33e8c262567ac46f4db3f8">tcpip_callbackmsg_trycallback</a> (struct tcpip_callback_msg *msg)</td></tr>
<tr class="separator:ga83fe5fb2ea33e8c262567ac46f4db3f8"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga56a234f3d895791225c3c850bfadb666"><td class="memItemLeft" align="right" valign="top"><a class="el" href="group__infrastructure__errors.html#gaf02d9da80fd66b4f986d2c53d7231ddb">err_t</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__lwip__os.html#ga56a234f3d895791225c3c850bfadb666">tcpip_callbackmsg_trycallback_fromisr</a> (struct tcpip_callback_msg *msg)</td></tr>
<tr class="separator:ga56a234f3d895791225c3c850bfadb666"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga1f3a88b8df6ba3b9ed1c00e0a305e3db"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__lwip__os.html#ga1f3a88b8df6ba3b9ed1c00e0a305e3db">tcpip_init</a> (<a class="el" href="tcpip_8h.html#a5fe07216c441e27c3028bcac60fa0992">tcpip_init_done_fn</a> initfunc, void *arg)</td></tr>
<tr class="separator:ga1f3a88b8df6ba3b9ed1c00e0a305e3db"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a5cdcb6b784fe0e8736a5b31a5cfbed6c"><td class="memItemLeft" align="right" valign="top"><a class="el" href="group__infrastructure__errors.html#gaf02d9da80fd66b4f986d2c53d7231ddb">err_t</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="tcpip_8c.html#a5cdcb6b784fe0e8736a5b31a5cfbed6c">pbuf_free_callback</a> (struct <a class="el" href="structpbuf.html">pbuf</a> *p)</td></tr>
<tr class="separator:a5cdcb6b784fe0e8736a5b31a5cfbed6c"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a55b4de3765c6a37b3f2b26a11603771c"><td class="memItemLeft" align="right" valign="top"><a class="el" href="group__infrastructure__errors.html#gaf02d9da80fd66b4f986d2c53d7231ddb">err_t</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="tcpip_8c.html#a55b4de3765c6a37b3f2b26a11603771c">mem_free_callback</a> (void *m)</td></tr>
<tr class="separator:a55b4de3765c6a37b3f2b26a11603771c"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="var-members"></a>
Variables</h2></td></tr>
<tr class="memitem:acd7be2108e9a47fd8f1ab0a49f76241d"><td class="memItemLeft" align="right" valign="top">sys_mutex_t&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="tcpip_8c.html#acd7be2108e9a47fd8f1ab0a49f76241d">lock_tcpip_core</a></td></tr>
<tr class="separator:acd7be2108e9a47fd8f1ab0a49f76241d"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table>
<a name="details" id="details"></a><h2 class="groupheader">Detailed Description</h2>
<div class="textblock"><p>Sequential API Main thread module </p>
</div><h2 class="groupheader">Function Documentation</h2>
<a id="a55b4de3765c6a37b3f2b26a11603771c"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a55b4de3765c6a37b3f2b26a11603771c">&#9670;&nbsp;</a></span>mem_free_callback()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="group__infrastructure__errors.html#gaf02d9da80fd66b4f986d2c53d7231ddb">err_t</a> mem_free_callback </td>
          <td>(</td>
          <td class="paramtype">void *&#160;</td>
          <td class="paramname"><em>m</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">
<p>A simple wrapper function that allows you to free heap memory from interrupt context.</p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">m</td><td>the heap memory to free </td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>ERR_OK if callback could be enqueued, an err_t if not </dd></dl>

</div>
</div>
<a id="a5cdcb6b784fe0e8736a5b31a5cfbed6c"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a5cdcb6b784fe0e8736a5b31a5cfbed6c">&#9670;&nbsp;</a></span>pbuf_free_callback()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="group__infrastructure__errors.html#gaf02d9da80fd66b4f986d2c53d7231ddb">err_t</a> pbuf_free_callback </td>
          <td>(</td>
          <td class="paramtype">struct <a class="el" href="structpbuf.html">pbuf</a> *&#160;</td>
          <td class="paramname"><em>p</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">
<p>A simple wrapper function that allows you to free a pbuf from interrupt context.</p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">p</td><td>The pbuf (chain) to be dereferenced. </td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>ERR_OK if callback could be enqueued, an err_t if not </dd></dl>

</div>
</div>
<a id="a3d42b0c46607f91aedcc7745ed466b08"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a3d42b0c46607f91aedcc7745ed466b08">&#9670;&nbsp;</a></span>tcpip_api_call()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="group__infrastructure__errors.html#gaf02d9da80fd66b4f986d2c53d7231ddb">err_t</a> tcpip_api_call </td>
          <td>(</td>
          <td class="paramtype">tcpip_api_call_fn&#160;</td>
          <td class="paramname"><em>fn</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">struct tcpip_api_call_data *&#160;</td>
          <td class="paramname"><em>call</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">
<p>Synchronously calls function in TCPIP thread and waits for its completion. It is recommended to use LWIP_TCPIP_CORE_LOCKING (preferred) or LWIP_NETCONN_SEM_PER_THREAD. If not, a semaphore is created and destroyed on every call which is usually an expensive/slow operation. </p><dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">fn</td><td>Function to call </td></tr>
    <tr><td class="paramname">call</td><td>Call parameters </td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>Return value from tcpip_api_call_fn </dd></dl>

</div>
</div>
<a id="a93043b3c66dbe4a15a60299c6199d102"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a93043b3c66dbe4a15a60299c6199d102">&#9670;&nbsp;</a></span>tcpip_inpkt()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="group__infrastructure__errors.html#gaf02d9da80fd66b4f986d2c53d7231ddb">err_t</a> tcpip_inpkt </td>
          <td>(</td>
          <td class="paramtype">struct <a class="el" href="structpbuf.html">pbuf</a> *&#160;</td>
          <td class="paramname"><em>p</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">struct <a class="el" href="structnetif.html">netif</a> *&#160;</td>
          <td class="paramname"><em>inp</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="netif_8h.html#ab2302b1b64ac7b95f24c6bab754a575e">netif_input_fn</a>&#160;</td>
          <td class="paramname"><em>input_fn</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">
<p>Pass a received packet to tcpip_thread for input processing</p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">p</td><td>the received packet </td></tr>
    <tr><td class="paramname">inp</td><td>the network interface on which the packet was received </td></tr>
    <tr><td class="paramname">input_fn</td><td>input function to call </td></tr>
  </table>
  </dd>
</dl>

</div>
</div>
<a id="a12bdf37eddcd72c4178e3ea7d370395d"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a12bdf37eddcd72c4178e3ea7d370395d">&#9670;&nbsp;</a></span>tcpip_send_msg_wait_sem()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="group__infrastructure__errors.html#gaf02d9da80fd66b4f986d2c53d7231ddb">err_t</a> tcpip_send_msg_wait_sem </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="tcpip_8h.html#a35203296bb838f3b493839ffc6e7285d">tcpip_callback_fn</a>&#160;</td>
          <td class="paramname"><em>fn</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">void *&#160;</td>
          <td class="paramname"><em>apimsg</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">sys_sem_t *&#160;</td>
          <td class="paramname"><em>sem</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">
<p>Sends a message to TCPIP thread to call a function. Caller thread blocks on on a provided semaphore, which ist NOT automatically signalled by TCPIP thread, this has to be done by the user. It is recommended to use LWIP_TCPIP_CORE_LOCKING since this is the way with least runtime overhead.</p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">fn</td><td>function to be called from TCPIP thread </td></tr>
    <tr><td class="paramname">apimsg</td><td>argument to API function </td></tr>
    <tr><td class="paramname">sem</td><td>semaphore to wait on </td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>ERR_OK if the function was called, another err_t if not </dd></dl>

</div>
</div>
<h2 class="groupheader">Variable Documentation</h2>
<a id="acd7be2108e9a47fd8f1ab0a49f76241d"></a>
<h2 class="memtitle"><span class="permalink"><a href="#acd7be2108e9a47fd8f1ab0a49f76241d">&#9670;&nbsp;</a></span>lock_tcpip_core</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">sys_mutex_t lock_tcpip_core</td>
        </tr>
      </table>
</div><div class="memdoc">
<p>The global semaphore to lock the stack. </p>

</div>
</div>
</div><!-- contents -->
</div><!-- doc-content -->
<!-- start footer part -->
<div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
  <ul>
    <li class="navelem"><a class="el" href="dir_68267d1309a1af8e8297ef4c3efbcdba.html">src</a></li><li class="navelem"><a class="el" href="dir_da61e3e9a357748887e3ca8d7c5a0c16.html">api</a></li><li class="navelem"><a class="el" href="tcpip_8c.html">tcpip.c</a></li>
    <li class="footer">Generated by
    <a href="http://www.doxygen.org/index.html">
    <img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.8.13 </li>
  </ul>
</div>
</body>
</html>
